home *** CD-ROM | disk | FTP | other *** search
/ Super PC 31 / Super PC 31 (Shareware).iso / spc / inter / speakf / fuente / init.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-28  |  3.0 KB  |  112 lines

  1. /*
  2.  
  3.                 Global application initialisation
  4.                 
  5. */
  6.  
  7. #include "netfone.h"
  8.  
  9. static LPSTR pszFrameClass;                // MDI frame window class
  10. LPSTR pszMDIClientClass;                // MDI client window class
  11. LPSTR pszClientClass;                    // MDI child window class
  12. static LPSTR pszServerClass;            // MDI child window class
  13.  
  14. //    INITAPPLICATION  --  Initialise globals and register classes
  15.  
  16. BOOL InitApplication(HINSTANCE hInstance)
  17. {
  18.     WNDCLASS WndClass;
  19.  
  20.     hInst = hInstance;
  21.  
  22.     //  Initialise some of the global strings
  23.  
  24. #if NETFONE_COMMAND_PORT == 2074
  25.     pszAppName = "Speak Freely";
  26. #else
  27.     //    Just so we don't accidentally ship one with a nonstandard port
  28.     pszAppName = "EXPERIMENTAL Speak Freely";
  29. #endif    
  30.     pszFrameClass = "SpeakFreeFrameClass";
  31.     pszMDIClientClass = "MDICLIENT";
  32.     pszClientClass = "SpeakFreeClientClass";
  33.  
  34.     //  Initialise & register the various window classes
  35.     
  36.     //    Main (frame) window
  37.  
  38.     WndClass.style = CS_HREDRAW | CS_VREDRAW;
  39.     WndClass.lpfnWndProc = (WNDPROC) Frame_WndProc;
  40.     WndClass.cbClsExtra = 0;
  41.     WndClass.cbWndExtra = 0;
  42.     WndClass.hInstance = hInstance;
  43.     WndClass.hIcon = LoadIcon(hInstance, IDI_FRAME);
  44.     WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
  45.     WndClass.hbrBackground = GetStockObject(WHITE_BRUSH);
  46.     WndClass.lpszMenuName = IDM_FRAME;
  47.     WndClass.lpszClassName = pszFrameClass;
  48.  
  49.     if (!RegisterClass(&WndClass)) {
  50.         return FALSE;
  51.     }
  52.     
  53.     //    Connection client window
  54.     
  55.     WndClass.style |= CS_DBLCLKS;
  56.     WndClass.lpfnWndProc = (WNDPROC) connectWndProc;
  57.     WndClass.cbWndExtra = sizeof(LPVOID);
  58.     WndClass.hCursor = NULL;
  59.     WndClass.hIcon = LoadIcon(hInstance, IDI_CLIENT);
  60.     WndClass.lpszMenuName = NULL;
  61.     WndClass.lpszClassName = pszClientClass;
  62.  
  63.     if (!RegisterClass(&WndClass)) {
  64.         return FALSE;
  65.     }
  66.     return TRUE;
  67. }
  68.  
  69. //    INITINSTANCE  --  Initialise a new instance
  70.  
  71. BOOL InitInstance(HINSTANCE hInstance, LPSTR pszCmdLine, INT nCmdShow)
  72. {
  73.     RECT r;
  74.     
  75.     /*    Save the command line so we can use it later to open a
  76.         connection file specified there.  */
  77.  
  78.     if (_fstrlen(pszCmdLine) > 0) {
  79.         commandLine = (LPSTR) GlobalAllocPtr(GPTR, _fstrlen(pszCmdLine) + 1);
  80.         if (commandLine != NULL) {
  81.             _fstrcpy(commandLine, pszCmdLine);
  82.         }
  83.     }    
  84.     
  85.     //  Create the frame window
  86.  
  87.     GetWindowRect(GetDesktopWindow(), &r);
  88.     hwndMDIFrame = CreateWindow(pszFrameClass, pszAppName, WS_OVERLAPPEDWINDOW,
  89.                                  CW_USEDEFAULT, CW_USEDEFAULT,
  90.                                  (r.right - r.left) / 2, (r.bottom - r.top) / 2,
  91.                                  NULL, NULL, hInstance, NULL);
  92.  
  93.     if (hwndMDIFrame == NULL) {
  94.         return FALSE;
  95.     }
  96.  
  97.     //  Load our accelerators
  98.  
  99.     hAccel = LoadAccelerators(hInst, IDA_FRAME);
  100.  
  101.     if (hAccel == NULL) {
  102.         return FALSE;
  103.     }
  104.  
  105.     //  Display the main window
  106.  
  107.     ShowWindow(hwndMDIFrame, nCmdShow);
  108.     UpdateWindow(hwndMDIFrame);
  109.     return TRUE;
  110. }
  111.  
  112.